package com.zr.d_c.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.d_c.model.Seller;
import com.zr.d_c.model.User;
import com.zr.d_c.service.UserInfoService;
import com.zr.d_c.serviceimpl.UserInfoServiceImpl;
/**
 * 更新商家的个人信息
 * @author Administrator
 *
 */
public class EditSinfoController extends HttpServlet{
	Seller seller = new Seller();
	UserInfoService userinfoservice = new UserInfoServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {	
		seller.setSname(req.getParameter("editsname"));			
		seller.setSaddress(req.getParameter("editsaddress"));		
		seller.setSphone(req.getParameter("editsphone"));
		seller.setSemail(req.getParameter("editsemail"));
		HttpSession session = req.getSession();
		User u = (User) session.getAttribute("currentUser");
		seller.setUid(u.getUid());	
		PrintWriter pw = resp.getWriter();		
		if (userinfoservice.updateSinfo(seller)) {		
			
			pw.write("1");
		
			
		}
		else {
			pw.write("0");
		}
	}

}
